package com.server.questionbank.snframe.domain.Course;

import com.server.questionbank.snframe.domain.Course.Result.RCourseComment;
import com.server.questionbank.snframe.service.UsersService.UsersService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;

@Data
public class CourseComment {
    private Long commentId;
    private Long courseId;
    private Long userId;
    private Long parentId;
    private String content;
    private Float score;
    private String createDate;

    public RCourseComment toRCourseComment(UsersService usersService) {
        RCourseComment rCourseComment = new RCourseComment();
        rCourseComment.setCommentId(this.commentId);
        rCourseComment.setCourseId(this.courseId);
        rCourseComment.setUserId(this.userId);
        rCourseComment.setParentId(this.parentId);
        rCourseComment.setContent(this.content);
        rCourseComment.setScore(this.score);
        rCourseComment.setCreateDate(this.createDate);
        if (this.userId != null) rCourseComment.setUserInfo(usersService.selectUserById(this.userId));
        return rCourseComment;
     }
}
